<%@ Page Title="" Language="C#" MasterPageFile="~/Areas/Admin/Views/Shared/Admin.Master" Inherits="System.Web.Mvc.ViewPage<IEnumerable<mesoBoard.Data.Group>>" %>

<asp:Content ID="Content1" ContentPlaceHolderID="MainContent" runat="server">
        /*public ActionResult Groups()
        {
            IEnumerable<Group> Groups = Services.Groups.GetGroups();
            return View(Groups);
        }

        [HttpGet]
        public ActionResult EditGroup(int GroupID)
        {
            ViewData["ForumPermissionID"] = new SelectList(Services.Permissions.GetForumPermissions(), "ForumPermissionID", "Name");
            return View(Services.Groups.GetGroup(GroupID));
        }

        [HttpPost]
        public ActionResult EditGroup(Group TheGroup)
        {
            ViewData["ForumPermissionID"] = new SelectList(Services.Permissions.GetForumPermissions(), "ForumPermissionID", "Name");
            if (ModelState.IsValid)
            {
                Services.Groups.UpdateGroup(TheGroup);
                SetSuccess("Group updated";
                return RedirectToAction("Groups");
            }
            else
            {
                SetError("Validation error";
                return View();
            }
        }

        [HttpGet]
        public ActionResult CreateGroup()
        {
            ViewData["ForumPermissionID"] = new SelectList(Services.Permissions.GetForumPermissions(), "ForumPermissionID", "Name");
            return View();
        }

        [HttpPost]
        public ActionResult CreateGroup(Group TheGroup)
        {
            ViewData["ForumPermissionID"] = new SelectList(Services.Permissions.GetForumPermissions(), "ForumPermissionID", "Name");
            if (ModelState.IsValid)
            {
                Services.Groups.CreateGroup(TheGroup);
                SetSuccess("Group created";
                return RedirectToAction("Groups");
            }
            else
            {
                SetError("Validation error";
                return View();
            }
        }

        public ActionResult DeleteGroup(int GroupID)
        {
            Services.Groups.DeleteGroup(GroupID);
            SetSuccess("Group deleted";
            return RedirectToAction("Groups");
        }*/
    <fieldset>
        <legend><%= Html.ThemeImage("user_black_female.png")%> Groups</legend>

        <%= Html.ImageLink("Create Group", Url.Action("CreateGroup"), "~/Themes/Default/Images/add.png", "Create Group", "image_link")%>
                       
        <table class="form_table"> 
        
            <tr>
                <th>Name</th>
                <th>Image</th>
                <th>Permissions</th>
                <th>Color</th>
                <th></th>
                <th></th>
            </tr>
            
            <% foreach(var g in Model){ %>
                <tr>
                    <td><%= g.Name %></td>
                    <td><%= Html.Image("~/Images/Groups/"+g.Image) %></td>
                    <td><%= Html.ActionLink(g.ForumPermission.Name, "EditForumPermission", new { ForumPermissionID = g.ForumPermissionsID}) %></td>
                    <td><span style="color:<%= g.Color%>"><%= g.Color %></span></td>
                    <td><%= Html.ActionLink("Edit", "EditRank", new { RankID = g.GroupID })%></td>
                    <td><%= Html.AdminConfirm("Delete", Url.Action("DeleteGroup", new { GroupID = g.GroupID }), Url.Action("Groups"))%></td>
                </tr>
            <%} %>
            
        </table>
        
    </fieldset>

</asp:Content>
